QuickOPC User's Guide and Reference
Obtaining Information (OPC UA Alarms & Conditions)
View with Navigation Tools
Development Models > Imperative Programming Model > Imperative Programming Model for OPC UA Alarms & Conditions > Obtaining Information (OPC UA Alarms & Conditions)

For obtaining information related to Alarms & Conditions (such as the state of conditions), OPC UA does not introduce any new mechanism over what we have already described for OPC Data (in OPC UA). Please refer to the “Obtaining Information” under “Imperative Programming Model for OPC Data (Class and UA)” for all necessary information.

Methods (and extension methods) such as EasyUAClient.Read, ReadMultiple, ReadValue, ReadMultipleValues can be used.

 

// This example shows how to read a Low state of a limit alarm. Note that you should not normally read a state of an alarm
// from inside its event notification, because the state might have already changed. Instead, include the information you
// need in the Select clauses when subscribing for the event.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.Navigation;

namespace UADocExamples.AlarmsAndConditions
{
    class ReadAlarmState
    {
        public static void Main1()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer";

            UANodeDescriptor alarmNodeDescriptor = new UANodeId(
                namespaceUriString:"http://opcfoundation.org/Quickstarts/AlarmCondition", 
                identifier:"1:Colours/EastTank?Yellow");

            // Knowing the alarm node, and the fact that is an instance of NonExclusiveLevelAlarmType (or its subtype),
            // determine what is its LowState/Id node.
            UANodeDescriptor lowStateIdNodeDescriptor = new UABrowsePath(alarmNodeDescriptor,
                new []
                {
                    UABrowsePathElement.CreateSimple("ns=0;s=LowState"),
                    UABrowsePathElement.CreateSimple("ns=0;s=Id")
                });

            // Instantiate the client object.
            var client = new EasyUAClient();

            Console.WriteLine("Reading alarm state...");
            var lowStateId = (bool)client.ReadValue(endpointDescriptor, lowStateIdNodeDescriptor);

            Console.WriteLine($"Id of LowState: {lowStateId}");
        }
    }
}

 

 

See Also